package flca.projbuilder;

import java.util.Set;

import flca.projbuilder.dto.TemplateDto;
import flca.projbuilder.gui.ICloseGui;
import flca.projbuilder.gui.AskValuesGui;
import flca.projbuilder.util.ProjbuildHelper;
import flca.projbuilder.util.TemplateDtoHelper;

public class ProjectBuilder implements ICloseGui {

	private AskValuesGui ex;
	
	public static void main(String[] args) {
		Set<TemplateDto> templates = TemplateDtoHelper.findAllTemplates();
		ProjectBuilder bldmain = new ProjectBuilder();
		bldmain.exec(templates);
	}

	public ProjectBuilder() {
	}

	public void exec(final Set<TemplateDto> aTemplates) {
		ex = new AskValuesGui(aTemplates, this);
		ex.setVisible(true);
	}
	
	@Override
	public void onFinish(TemplateDto aTemplateData) {	
		System.out.println(aTemplateData);
		ex.dispose();
		ex = null;
		doGenerate(aTemplateData);
	}
	
	private void doGenerate(TemplateDto aTemplate) {
		ProjbuildHelper helper = new ProjbuildHelper();
		helper.doGenerate(aTemplate);
	}
	
}
